<script type="text/html" template lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-StudioManagement-createForm" id="LAY-app-StudioManagement-createForm">

        <div class="layui-form-item">
            <label for="name" class="layui-form-label  layui-form-required">直播间名字</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="name" lay-verify="required|verifyname" class="layui-input" lay-reqText="请输入直播间名字" placeholder="请输入直播间名字" />
            </div>
            <div class="layui-form-mid">直播间名字，最短3个汉字，最长17个汉字</div>
        </div>

        <div class="layui-form-item">
            <label for="coverImg" class="layui-form-label  layui-form-required">背景图</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="coverImg" id="coverImg" lay-verify="required" class="layui-input" lay-reqText="请输入背景图" placeholder="请输入背景图" />
            </div>
            <div class="layui-input-inline layui-inline-2">
                <button type="button" class="layui-btn" id="upBtn_coverImg">点击上传</button>
            </div>
            <div class="layui-form-mid">建议像素1080*1920，大小不超过2M</div>
        </div>

        <div class="layui-form-item">
            <label for="startTime" class="layui-form-label  layui-form-required">计划开始时间</label>
            <div class="layui-input-inline layui-inline-3">
                <input name="startTime" id="createTime-StudioManagement-startTime" type="text" lay-verify="required|datetime" class="layui-input" placeholder="请输入计划开始时间" lay-reqText="请输入计划开始时间" value="{{layui.util.toDateString((new Date()).setMinutes((new Date()).getMinutes() + 20), 'yyyy-MM-dd HH:mm:ss')	}}" />
            </div>
            <div class="layui-form-mid">开播时间需要在当前时间的10分钟后 并且开始时间不能在 6 个月后</div>
        </div>

        <div class="layui-form-item">
            <label for="endTime" class="layui-form-label  layui-form-required">计划结束时间</label>
            <div class="layui-input-inline layui-inline-3">
                <input name="endTime" id="createTime-StudioManagement-endTime" type="text" lay-verify="required|datetime" class="layui-input" placeholder="请输入计划结束时间" lay-reqText="请输入计划结束时间" value="{{layui.util.toDateString((new Date()).setHours((new Date()).getHours() + 23), 'yyyy-MM-dd HH:mm:ss')	}}" />
            </div>
            <div class="layui-form-mid">开播时间和结束时间间隔不得短于30分钟，不得超过24小时</div>
        </div>


        <div class="layui-form-item">
            <label for="anchorName" class="layui-form-label  layui-form-required">主播昵称</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="anchorName" lay-verify="required|verifyAnchorName" class="layui-input" lay-reqText="请输入主播昵称" placeholder="请输入主播昵称" />
            </div>
            <div class="layui-form-mid">最短2个汉字，最长15个汉字，1个汉字相当于2个字符</div>
        </div>

        <div class="layui-form-item">
            <label for="anchorWechat" class="layui-form-label  layui-form-required">主播微信号</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="anchorWechat" lay-verify="required" class="layui-input" lay-reqText="请输入主播微信号" placeholder="请输入主播微信号" />
            </div>
            <div class="layui-form-mid">如果未实名认证，需要先前往“小程序直播”小程序进行实名验证, <a href="https://res.wx.qq.com/op_res/9rSix1dhHfK4rR049JL0PHJ7TpOvkuZ3mE0z7Ou_Etvjf-w1J_jVX0rZqeStLfwh" target="_blank" class="text-red">【点击前往认证】</a></div>
        </div>

        <div class="layui-form-item">
            <label for="subAnchorWechat" class="layui-form-label">主播副号微信号</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="subAnchorWechat" class="layui-input" lay-reqText="请输入主播副号微信号" placeholder="请输入主播副号微信号" />
            </div>
            <div class="layui-form-mid">如果未实名认证，需要先前往“小程序直播”小程序进行实名验证, <a href="https://res.wx.qq.com/op_res/9rSix1dhHfK4rR049JL0PHJ7TpOvkuZ3mE0z7Ou_Etvjf-w1J_jVX0rZqeStLfwh" target="_blank" class="text-red">【点击前往认证】</a></div>
        </div>

        <div class="layui-form-item">
            <label for="createrWechat" class="layui-form-label">创建者微信号</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="createrWechat" class="layui-input" lay-reqText="请输入创建者微信号" placeholder="请输入创建者微信号" />
            </div>
            <div class="layui-form-mid">不传入则此直播间所有成员可见。传入则此房间仅创建者、管理员、超管、直播间主播可见</div>
        </div>

        <div class="layui-form-item">
            <label for="shareImg" class="layui-form-label layui-form-required">分享图</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="shareImg" id="shareImg" class="layui-input" lay-reqText="请输入分享图" placeholder="请输入分享图" />
            </div>
            <div class="layui-input-inline layui-inline-2">
                <button type="button" class="layui-btn" id="upBtn_shareImg">点击上传</button>
            </div>
            <div class="layui-form-mid">图片规则：建议像素800*640，大小不超过1M</div>
        </div>

        <div class="layui-form-item">
            <label for="feedsImg" class="layui-form-label layui-form-required">频道封面图</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="feedsImg" id="feedsImg" class="layui-input" lay-reqText="请输入频道封面图" placeholder="请输入频道封面图" />
            </div>
            <div class="layui-input-inline layui-inline-2">
                <button type="button" class="layui-btn" id="upBtn_feedsImg">点击上传</button>
            </div>
            <div class="layui-form-mid">图片规则：建议像素800*800，大小不超过100KB</div>
        </div>


        <div class="layui-form-item">
            <label for="isFeedsPublic" class="layui-form-label ">开启官方收录</label>
            <div class="layui-input-inline">
                <input type="radio" name="isFeedsPublic" value="1" title="开启" checked>
                <input type="radio" name="isFeedsPublic" value="0" title="关闭">
            </div>
            <div class="layui-form-mid">默认开启收录</div>
        </div>

        <div class="layui-form-item">
            <label for="type" class="layui-form-label ">直播间类型</label>
            <div class="layui-input-inline">
                <input type="radio" name="type" value="1" title="推流">
                <input type="radio" name="type" value="0" title="手机" checked>
            </div>
            <div class="layui-form-mid">推流需要使用软件将本地直播流推送到直播间推流地址，手机只需要打开小程序直播</div>
        </div>

        <div class="layui-form-item">
            <label for="closeLike" class="layui-form-label ">是否关闭点赞</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeLike" value="0" title="开启" checked>
                <input type="radio" name="closeLike" value="1" title="关闭">
            </div>
            <div class="layui-form-mid">若关闭，观众端将隐藏点赞按钮，直播开始后不允许开启</div>
        </div>

        <div class="layui-form-item">
            <label for="closeGoods" class="layui-form-label ">是否关闭货架</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeGoods" value="0" title="开启" checked>
                <input type="radio" name="closeGoods" value="1" title="关闭">
            </div>
            <div class="layui-form-mid">若关闭，观众端将隐藏商品货架，直播开始后不允许开启</div>
        </div>

        <div class="layui-form-item">
            <label for="closeComment" class="layui-form-label ">是否关闭评论</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeComment" value="0" title="开启" checked>
                <input type="radio" name="closeComment" value="1" title="关闭">
            </div>
            <div class="layui-form-mid">若关闭，观众端将隐藏评论入口，直播开始后不允许开启</div>
        </div>

        <div class="layui-form-item">
            <label for="closeReplay" class="layui-form-label ">是否关闭回放</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeReplay" value="0" title="开启">
                <input type="radio" name="closeReplay" value="1" title="关闭" checked>
            </div>
            <div class="layui-form-mid">默认关闭回放（直播开始后允许开启）</div>
        </div>

        <div class="layui-form-item">
            <label for="closeShare" class="layui-form-label ">是否关闭分享</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeShare" value="0" title="开启" checked>
                <input type="radio" name="closeShare" value="1" title="关闭">
            </div>
            <div class="layui-form-mid">默认开启分享（直播开始后不允许修改）</div>
        </div>

        <div class="layui-form-item">
            <label for="closeKf" class="layui-form-label ">是否关闭客服</label>
            <div class="layui-input-inline">
                <input type="radio" name="closeKf" value="0" title="开启" checked>
                <input type="radio" name="closeKf" value="1" title="关闭">
            </div>
            <div class="layui-form-mid">默认关闭客服（直播开始后允许开启）</div>
        </div>

        <div class="layui-form-item text-right core-hidden">
            <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-StudioManagement-createForm-submit" id="LAY-app-StudioManagement-createForm-submit" value="确认添加">
        </div>
    </div>
</script>
<script>
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
            function () {
                var $ = layui.$
                    , form = layui.form
                    , admin = layui.admin
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , cropperImg = layui.cropperImg
                    , coreHelper = layui.coreHelper;

                upload.render({
                    elem: '#upBtn_coverImg'
                    , url: layui.setter.apiUrl + 'Api/Tools/New_Temporary_Materials_UploadImg'
                    , before: function (obj) {
                        obj.preview(function (index, file, result) {
                            layer.msg('上传中', { icon: 16, shade: 0.4 });
                        });
                    }
                    , done: function (res) {
                        layer.closeAll('loading'); //关闭加载层
                        if (res.code > 0) {
                            return layer.msg('上传失败');
                        }
                        layer.msg('上传成功');
                        $("#coverImg").val(res.data.mediaId);
                    }
                    , error: function (res) {
                        layer.msg('上传失败，请重试');
                        console.log(res);
                    }
                });

                upload.render({
                    elem: '#upBtn_shareImg'
                    , url: layui.setter.apiUrl + 'Api/Tools/New_Temporary_Materials_UploadImg'
                    , before: function (obj) {
                        obj.preview(function (index, file, result) {
                            layer.msg('上传中', { icon: 16, shade: 0.4 });
                        });
                    }
                    , done: function (res) {
                        layer.closeAll('loading'); //关闭加载层
                        if (res.code > 0) {
                            return layer.msg('上传失败');
                        }
                        layer.msg('上传成功');
                        $("#shareImg").val(res.data.mediaId);
                    }
                    , error: function (res) {
                        layer.msg('上传失败，请重试');
                        console.log(res);
                    }
                });

                upload.render({
                    elem: '#upBtn_feedsImg'
                    , url: layui.setter.apiUrl + 'Api/Tools/New_Temporary_Materials_UploadImg'
                    , before: function (obj) {
                        obj.preview(function (index, file, result) {
                            layer.msg('上传中', { icon: 16, shade: 0.4 });
                        });
                    }
                    , done: function (res) {
                        layer.closeAll('loading'); //关闭加载层
                        if (res.code > 0) {
                            return layer.msg('上传失败');
                        }
                        layer.msg('上传成功');
                        $("#feedsImg").val(res.data.mediaId);
                    }
                    , error: function (res) {
                        layer.msg('上传失败，请重试');
                        console.log(res);
                    }
                });

                form.verify({
                    verifyname: [/^.{3,17}$/, '直播间名字，最短3个汉字，最长17个汉字'],
                    verifyAnchorName: [/^.{2,17}$/, '主播昵称，最短2个汉字，最长15个汉字，1个汉字相当于2个字符'],
                    verifydescription: [/^.{0,500}$/, '等级说明最大只允许输入500位字符'],
                });

                laydate.render({
                    elem: '#createTime-StudioManagement-startTime',
                    type: 'datetime'
                });
                laydate.render({
                    elem: '#createTime-StudioManagement-endTime',
                    type: 'datetime'
                });

                //重载form
                form.render(null, 'LAY-app-StudioManagement-createForm');
            })
    };
</script>
